package com.xbongbong.saas.enums;


import com.xbongbong.paas.enums.NodeTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author lee
 * @version v1.0
 * @date 2020/01/06 14:39
 * @since v1.0
 */

@Getter
public enum DefaultDistributorProcessEnum {
    //经销商回款单
    PAYMENT_SHEET_START(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "startNode", NodeTypeEnum.START_PROCESS_NODE.getNodeType(), "流程开始节点", "[]", "0",null,null, ""),
    PAYMENT_SHEET_2(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "1", 6, "", "[]","startNode",null,null,""),
    PAYMENT_SHEET_3(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "2", 5, "条件1", "[]","1",1,1, "1"),
    PAYMENT_SHEET_4(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "3", 5, "条件2", "[]","1",2,1, "1"),
    PAYMENT_SHEET_5(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "4", 5, "条件3", "[]", "1",3,1, "1"),
    PAYMENT_SHEET_6(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "5", 3, "审批节点", "[{\"editable\":1,\"id\":\"1\",\"name\":\"超级管理员\",\"property\":\"role\"},{\"editable\":1,\"id\":\"2\",\"name\":\"老板\",\"property\":\"role\"},{\"editable\":1,\"id\":\"20\",\"name\":\"财务\",\"property\":\"role\"}]", "2",null,null,"1"),
    PAYMENT_SHEET_7(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "6", 3, "审批节点", "[{\"editable\":1,\"id\":\"1\",\"name\":\"超级管理员\",\"property\":\"role\"},{\"editable\":1,\"id\":\"2\",\"name\":\"老板\",\"property\":\"role\"},{\"editable\":1,\"id\":\"20\",\"name\":\"财务\",\"property\":\"role\"}]", "3",null,null,"1"),

    //经销商销项发票
    INVOICE_START(XbbRefTypeEnum.INVOICE.getCode(), "startNode", 1, "流程开始节点", "[]", "0",null,null, ""),
    INVOICE_2(XbbRefTypeEnum.INVOICE.getCode(), "1", 3, "审批节点", "[{\"editable\":1,\"id\":\"1\",\"name\":\"超级管理员\",\"property\":\"role\"},{\"editable\":1,\"id\":\"2\",\"name\":\"老板\",\"property\":\"role\"},{\"editable\":1,\"id\":\"20\",\"name\":\"财务\",\"property\":\"role\"}]", "startNode",null,null, null),

    // 临时额度 - 开始->渠道主管->财务->结束
    CREDIT_TEMPORARY_START(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT.getCode(), "startNode", 1, "流程开始节点", "[]", "0",null,null, ""),
    CREDIT_TEMPORARY_2(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT.getCode(), "1", 3, "审批节点", "[{\"editable\":1,\"id\":\"1\",\"name\":\"超级管理员\",\"property\":\"role\"},{\"editable\":1,\"id\":\"2\",\"name\":\"老板\",\"property\":\"role\"},{\"editable\":1,\"id\":\"20\",\"name\":\"财务\",\"property\":\"role\"}]", "startNode",null,null, null),

    // 固定额度 - 开始->渠道主管->财务->结束
    CREDIT_FIXED_START(XbbRefTypeEnum.CREDIT_FIXED_LIMIT.getCode(), "startNode", 1, "流程开始节点", "[]", "0",null,null, ""),
    CREDIT_FIXED_2(XbbRefTypeEnum.CREDIT_FIXED_LIMIT.getCode(), "1", 3, "审批节点", "[{\"editable\":1,\"id\":\"1\",\"name\":\"超级管理员\",\"property\":\"role\"},{\"editable\":1,\"id\":\"2\",\"name\":\"老板\",\"property\":\"role\"},{\"editable\":1,\"id\":\"20\",\"name\":\"财务\",\"property\":\"role\"}]", "startNode",null,null, null),

    RETURN_START(XbbRefTypeEnum.REFUND.getCode(), "startNode", 1, "流程开始节点", "[]", "0",null,null, ""),
    RETURN_2(XbbRefTypeEnum.REFUND.getCode(), "1", 3, "审批节点", "[{\"attr\":\"ownerId\",\"editable\":1,\"id\":\"0\",\"name\":\"负责人\",\"property\":\"dynamicManager\"}]", "startNode",null,null, null),

    ;
    /*需要自己加field_permission,corpid,appId,menuId,formId,templateId,condition*/
    DefaultDistributorProcessEnum(Integer businessType, String uid, Integer type, String name, String mainUser,  String prevId, Integer priority, Integer conditionType, String wrapperId) {
        this.businessType = businessType;
        this.uid = uid;
        this.type = type;
        this.name = name;
        this.mainUser = mainUser;
        this.prevId = prevId;
        this.priority = priority;
        this.conditionType = conditionType;
        this.wrapperId = wrapperId;
    }

    private Integer businessType;

    /**
     * 前端唯一标识
     */
    private String uid;
    /**
     * 节点类型，1.开始节点，2.结束节点，3.流程节点，4.抄送节点
     * @see com.xbongbong.pro.enums.fund.enums.ModelTypeEnum
     */
    private Integer type;
    /**
     * 节点名称
     */
    private String name;
    /**
     * 节点负责人
     */
    private String mainUser;
    /**
     * 新模板用 上级节点id
     */
    private String prevId;
    /**
     * 新模板用 条件优先级
     */
    private Integer priority;
    /**
     * 流转条件类型,1使用自定义流转条件，2使用else条件
     */
    private Integer conditionType;
    /**
     * 条件块id
     */
    private String wrapperId;

    public static List<DefaultDistributorProcessEnum> getByBusinessType (Integer businessType) {
        List<DefaultDistributorProcessEnum> list = new ArrayList<>();
        for (DefaultDistributorProcessEnum defaultDistributorProcessEnum : DefaultDistributorProcessEnum.values()) {
            if (Objects.equals(defaultDistributorProcessEnum.getBusinessType(), businessType)) {
                list.add(defaultDistributorProcessEnum);
            }
        }
        return list;
    }

}
